package com.lin.ovc.pomodoro.controller;

import com.lin.ovc.pomodoro.entity.Record;
import com.lin.ovc.pomodoro.service.RecordService;
import com.lin.ovc.pomodoro.service.TaskService;
import com.lin.ovc.pomodoro.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/pomodoro")
public class PomodoroController {
    @Autowired
    TaskService taskService;

    @Autowired
    RecordService recordService;

    //	开启一个自定义的番茄钟 OpenCustomPomodoro()
    @PostMapping("/openCustomPomodoro")
    public R OpenCustomPomodoro(Long taskId, Long planId, String name, int time){
        Record record = new Record();
        Long UserId = 1L;
        record.setUserId(UserId);
        record.setTaskId(taskId);
        record.setPlanId(planId);
        record.setTime(time);
        record.setName(name);
        record.setCost(0);
        if(recordService.save(record)){
            return R.ok();
        }
        return R.error();
    }

    //	OpenPomodoro()
    @GetMapping("/openPomodoro")
    public R OpenPomodoro(){
        return R.ok();
    }
    //	CloseCustomPomodoro()
    @GetMapping("/closeCustomPomodoro")
    public R CloseCustomPomodoro(){

        return R.ok();
    }
    //  ClosePomodoro()
    @GetMapping("/closePomodoro")
    public R ClosePomodoro(){
        return R.ok();
    }
}
